/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * <p>Project: jse2302 - SetDemo
 * <p>Powered by webrx On 2023-06-25 14:28:15
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class SetDemo {
    public static void main(String[] args) {
        Set<Integer> ss = new HashSet<>();
        ss.addAll(List.of(10,20,30,10,20,10,10,10,50));
        System.out.println(ss.size());
        System.out.println(ss);

        //System.out.println(ss.containsAll(List.of(30, 500)));

        for(int i : ss){
            System.out.println(i);
        }
    }

    public static void demo(String[] args) {
        //Set<Integer> sets = new HashSet<>();
        //sets.add(6);
        //sets.add(2);
        //sets.add(9);
        //Integer a = new Integer(3);
        //sets.add(a);
        //System.out.println(a.hashCode());
        //Integer b = new Integer(3);
        //sets.add(b);
        ////System.out.println(b.hashCode());
        //System.out.println(a == b);
        ////System.out.println(sets.contains(a));
        ////System.out.println(sets.contains(b));
        //System.out.println(sets);



        Set<String> ss = new HashSet<>();
        ss.clear();
        ss.add(new String("hello"));
        String s = new String("hello");
        ss.add(s);
        System.out.println(ss.contains("hello"));
        ss.remove("hello");
        System.out.println(ss.size());
        System.out.println(ss);

        for(String str :ss){
            System.out.println(str == s);
        }

    }
}
